<?php
class TheChinhController extends Zend_Controller_Action
{

    public function init()
    {
      /*  $this->_arrParam = $this->_request->getParams();
		$this->view->arrParam = $this->_arrParam; */
    }

    public function indexAction()
    {
    	
    }

    public function dangkytheAction()
    {
    	//$this->view->title = 'Đăng ký thẻ trực tuyến';
    	$formThem = new Admin_Form_TheChinhForm();    	
    	$formThem->setMethod('post');
    	$formThem->setAction('/zfMHB/public/thechinh/dangkythe');
    	
    	$formThem->addElement('submit', 'submit', array('label' => 'Thêm'));
    	/* $formThem->getElement('hovaten')->addValidator('Db_NoRecordExists',true, array(
    			'table' => 'tbl_thechinh',
    			'field' => 'HoVaTen'
    	)); */
    	$this->view->form = $formThem;
    	
    	if($this->getRequest()->isPost()){
    		if($formThem->isValid($_POST)){
    			$data = $formThem->getValues();
    			
    			$machinhanh			= $data['machinhanh'];

				$hovaten 					= $data['hovaten'];
				$ngaysinh				= $data['ngaysinh'];
				$diachithuongtru = $data['diachithuongtru'];
				$diachilienlac			= $data['diachilienlac'];
				$cmnd 					= $data['cmnd'];
				$ngaycap					= $data['ngaycap'];
				$noicap					= $data['noicap'];				
				$dienthoai				= $data['dienthoai'];
				$tencoquan				= $data['tencoquan'];
				$dienthoaicoquan	=$data['dienthoaicoquan'];
				$diachicoquan			=$data['diachicoquan'];
				
    			$dangkytheMapper = Library_Model_DangKyTheMapper::getInstance();
    			$dangkytheObj 	= new Library_Model_DangKyThe();
    			    			
    			$dangkytheObj->setHovaten($hovaten);
				$dangkytheObj->setNgaysinh($ngaysinh);
				$dangkytheObj->setCmnd($cmnd);
				$dangkytheObj->setNgaycap($ngaycap);
				$dangkytheObj->setNoicap($noicap);
				$dangkytheObj->setDiachithuongtru($diachithuongtru);
				$dangkytheObj->setDiachilienlac($diachilienlac);
				$dangkytheObj->setDienthoai($dienthoai);
				$dangkytheObj->setTencoquan($tencoquan);
				$dangkytheObj->setTencoquan($tencoquan);
				$dangkytheObj->setDienthoaicoquan($dienthoaicoquan);
				$dangkytheObj->setDiachicoquan($diachicoquan);
				
				$dangkytheObj->setMachinhanh($machinhanh);
				$dangkytheObj->setNgaydangky(Zend_Date::now()->get('yyyy-MM-dd HH:mm:ss'));
				
				$dangkythe = $dangkytheMapper->save($dangkytheObj);
				$this->_helper->flashMessenger->addMessage(array('green'=>'Đăng ký thẻ thành công'));
    			$this->_redirect('/index');
    		}
    	}
    }

   public function gioithieutheAction(){}
   public function huongdanAction(){}
   public function validateformAction()
    {
        $user_id = $this->getRequest()->getParam('id');
        $this->_helper->viewRenderer()->setNoRender();
        $this->_helper->getHelper('layout')->disableLayout();
        $form = new Admin_Form_TheChinhForm();
        $form->isValid($this->_getAllParams());
        $json = $form->getMessages();
        header('Content-type: application/json');
        echo Zend_Json::encode($json);
    }


}









